package cn.elegent.tx.config;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 设置Mqtt
 * @author wgl
 */
@Configuration
@ConfigurationProperties(prefix="elegent.tx")
@Component
@Data
@Slf4j
public class RollBackConfig {

    @Value("${spring.application.name}")
    private String name;

    //用于暂存serverName的静态资源方便提取
    private static String serverName;

    /**
     * 每次等待时间
     */
    private Long waitTime = 1000l;

    /**
     * 最大循环次数
     */
    private int maxCycles = 5;

    @PostConstruct
    private void init(){
        serverName = name;
    }

    /**
     * 提取服务名的方法
     * @return
     */
    public static String getServerName() {
        return serverName;
    }
}
